package com.lijin.study.java.parseacct;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class ParsePPP {

	private static final String FOLDER_OLD = "D:\\0529_old";
	private static final String FOLDER_NEW = "D:\\0529_new\\";
	
	public static void main(String[] args) throws Exception {
		File oldFld = new File(FOLDER_OLD);
		for (File f : oldFld.listFiles()) {
			parseFile(f);
		}
	}
	
	private static void parseFile(File f) throws Exception {
		System.out.println("File-Info: begin.." + f.getName());
		File nf = new File(FOLDER_NEW + f.getName());
		BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(f), "GBK"));
		BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(nf), "GBK"));
		while (br.ready()) {
			String line = br.readLine();
			byte[] bytes = line.getBytes("GBK");
			String str = new String(bytes, 233, 18);
			System.out.println(str);
			if (!"".equals(str.trim())) {
				wr.write(line);
				wr.newLine();
			}
		}
		wr.close();
		br.close();
		System.out.println("File-Info: end..");
	}
}
